
import { _decorator, Component, Node, Sprite, Label } from 'cc';
import yyComponent from '../../Script/Common/yyComponent';
import { SignDataCfg } from './SignDataCfg';
const { ccclass, property } = _decorator;

@ccclass('SignItem')
export class SignItem extends yyComponent {

    @property(Sprite)
    protected icon: Sprite = null;

    @property(Label)
    protected goldLabel: Label = null;

    @property(Node)
    protected checkNode: Node = null;

    _dayId = 0;
    _clickCb = null;
    _isCheck = false;

    initData(_dayId: number, _isCheck: boolean, clickCb: Function) {
        this._dayId = _dayId;
        this._clickCb = clickCb;
        this._isCheck = _isCheck;
        //填充数据
        this.checkNode.active = this._isCheck;
        this.goldLabel.string = SignDataCfg[_dayId].val;
    }

    onClick() {
        if (this._isCheck) {
            return
        }
        this._clickCb && this._clickCb(this._dayId);
    }

    setCheckState(_isCheck) {
        this._isCheck = _isCheck;
        this.checkNode.active = this._isCheck;
    }

}
